package com.ydj.app.init;

import java.util.Date;

import com.ydj.app.entity.query.ForecastQuestionQuery;
import com.ydj.app.enumerate.ForecastQuestionCateEnum;

import com.google.common.collect.Lists;

import com.ydj.AppEnvironment;
import com.ydj.app.entity.ForecastQuestion;
import com.ydj.app.entity.dao.ForecastQuestionDao;
import com.ydj.app.protocol.dto.ForecastQaItemDto;
import com.ydj.framework.module.init.BaseInit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Component
public class ForecastQuestionInit extends BaseInit {
    @Autowired
    AppEnvironment appEnvironment;
    @Autowired
    ForecastQuestionDao forecastQuestionDao;

    @Override
    protected InitContext getContext() {
        return new InitContext("预测问题初始化", 6);
    }

    @Override
    protected void doAction() {
        // 企业
        {
            new ForecastQuestionQuery(forecastQuestionDao).cate(ForecastQuestionCateEnum.企业).remove();
            List<ForecastQaItemDto> list = new ArrayList<>();
            list.add(createInput("您的企业名称", ""));
            list.add(createInput("您的业务介绍", ""));
            list.add(createInput("您准备在国内做Pre-RWA还是香港RWA", ""));
            list.add(createInput("您做RWA的目的是战略布局还是募资", ""));
            list.add(createInput("您的企业/项目年收入", ""));
            list.add(createInput("您的企业/项目年增速", ""));
            list.add(createInput("请描述下您的企业上下游客户情况（100字以内）", "企业目标客户类型、客户数量、单个客户平均成交额"));
            list.add(createInput("您企业/项目过往融资情况", "融资时间规模，投资机构，股权或债权，债权请标记利率情况"));
            list.add(createInput("您布局RWA前期预算是多少", ""));
            list.add(createInput("您是否考虑借壳上市/上市公司合作", ""));
            list.add(createCheckBox("找白露会客厅的目的（多选）", Arrays.asList(
                    new ForecastQaItemDto.QaOptionsItem("报名白露私亨晚宴1688每位，每周日晚线下闭门深圳南山饭局。每次限12位"),
                    new ForecastQaItemDto.QaOptionsItem("深度链接:年度先锋会员2980元/每年，内部深度资料，及参与白露组织的腾讯云会议线上大咖闭门交流"),
                    new ForecastQaItemDto.QaOptionsItem("1V1咨询:单次付费咨询5000元/每小时，咨询您的项目RWA能否成功发行"),
                    new ForecastQaItemDto.QaOptionsItem("RWA方案:企业RWA战略方案落地报告及路演，3W一份"),
                    new ForecastQaItemDto.QaOptionsItem("顾问合作及拜师学习:月顾问/季度顾问/年顾问，3W起随缘，弟子班8.88W起，可定制需求，一线顶级大咖直接交流及线下由白露引荐见面，顶层战略咨询"),
                    new ForecastQaItemDto.QaOptionsItem("免费自由交流+加入未经筛选的免费粉丝群"),
                    new ForecastQaItemDto.QaOptionsItem("其他定制需求", "我希望能够...")
            )));
            ForecastQuestion question = new ForecastQuestion()
                    .setQuestionList(list)
                    .setCate(ForecastQuestionCateEnum.企业);
            forecastQuestionDao.saveOrUpdate(question);
        }

        // 个人
        {
            new ForecastQuestionQuery(forecastQuestionDao).cate(ForecastQuestionCateEnum.个人).remove();
            List<ForecastQaItemDto> list = new ArrayList<>();
            list.add(createInput("您的个人介绍", ""));
            list.add(createInput("您的人生目标", ""));
            list.add(createInput("您的RWA转型目标", ""));
            list.add(createInput("您的职位及年收入", ""));
            list.add(createInput("您的出生日期（阳历）", ""));
            list.add(createInput("您是哪里人", ""));
            list.add(createInput("您的性格特征", ""));
            list.add(createInput("您是否创过业？你在创业中团队的角色是什么", "一把手/二把手/三把手？前台/中台/后台? 冒险型/风控型?"));
            list.add(createInput("您做高管的时候曾经最多管理过多少人", ""));
            list.add(createInput("您的负债情况", ""));
            list.add(createInput("您的十六型人格（选填）", "", false));
            list.add(createCheckBox("找白露会客厅的目的（多选）", Arrays.asList(
                    new ForecastQaItemDto.QaOptionsItem("报名白露私亨晚宴1688每位，每周日晚线下闭门深圳南山饭局。每次限12位"),
                    new ForecastQaItemDto.QaOptionsItem("深度链接:年度先锋会员2980元/每年，内部深度资料，及参与白露组织的腾讯云会议线上大咖闭门交流"),
                    new ForecastQaItemDto.QaOptionsItem("1V1咨询:单次付费咨询5000元/每小时，咨询您的项目RWA能否成功发行"),
                    new ForecastQaItemDto.QaOptionsItem("RWA方案:企业RWA战略方案落地报告及路演，3W一份"),
                    new ForecastQaItemDto.QaOptionsItem("顾问合作及拜师学习:月顾问/季度顾问/年顾问，3W起随缘，弟子班8.88W起，可定制需求，一线顶级大咖直接交流及线下由白露引荐见面，顶层战略咨询"),
                    new ForecastQaItemDto.QaOptionsItem("免费自由交流+加入未经筛选的免费粉丝群"),
                    new ForecastQaItemDto.QaOptionsItem("其他定制需求", "我希望能够...")
            )));
            ForecastQuestion question = new ForecastQuestion()
                    .setQuestionList(list)
                    .setCate(ForecastQuestionCateEnum.个人);
            forecastQuestionDao.saveOrUpdate(question);
        }
    }

    private ForecastQaItemDto createInput(String label, String placeholder) {
        return createInput(label, placeholder, true);
    }

    private ForecastQaItemDto createInput(String label, String placeholder, Boolean required) {
        ForecastQaItemDto item = new ForecastQaItemDto()
                .setLabel(label)
                .setType(ForecastQaItemDto.Type.InputBox)
                .setPlaceholder(placeholder)
                .setRequired(required);
        return item;
    }

    private ForecastQaItemDto createCheckBox(String label, List<ForecastQaItemDto.QaOptionsItem> optionsItemList) {
        ForecastQaItemDto item = new ForecastQaItemDto()
                .setLabel(label)
                .setType(ForecastQaItemDto.Type.CheckBox)
                .setRequired(true)
                .setOptions(optionsItemList);
        return item;
    }
}